package com.example.common;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 统一返回信息实体类
 *
 * @author kangshuai
 */
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class ResultMessage<T> {

    private Integer status;
    /**
     * 返回状态详细信息
     */
    private String detail;
    /**
     * 返回具体数据
     */
    private T data;


    public static <T> ResultMessage<T> success(T object) {
        return new ResultMessage<T>().setStatus(0).setDetail("操作成功！").setData(object);
    }

    public static <T> ResultMessage<T> error(String message, T object) {
        return new ResultMessage<T>().setStatus(1).setDetail(message).setData(object);
    }
}